import QtQuick 1.0

// Displays item's data
Rectangle {
    id: dataBlock
    width: 250
    height: 60
    color: "#50000000"
    border.color: "orange"
    objectName: "dataBlock"

    property SystemPalette palette
    property int key: -1
    property string value: ""

    signal dataChanged(int key, string data)

    function commit()
    {
        value = infoEdit.text;
        dataChanged(key, value);
    }


    Rectangle {
        id: infoRect
        anchors.top: dataBlock.top
        height: dataBlock.height - commitButton.height - anchors.margins*2 - commitButton.anchors.margins
        anchors.margins: 5
        anchors.left: dataBlock.left
        anchors.right: dataBlock.right
        anchors.leftMargin: 9
        anchors.rightMargin: 9
        border.color: infoEdit.focus ? palette.light : Qt.darker(palette.light)
        color: palette.dark

        TextEdit {
            id: infoEdit
            anchors.fill: parent
            text: value
            anchors.margins: 2
        }
    }

    Button {
        id: commitButton
        radius: 5
        buttonText: "Применить"
        height:  dataBlock.height / 4
        anchors.left: dataBlock.left
        anchors.right: dataBlock.right
        anchors.bottom:  dataBlock.bottom
        anchors.margins: 3
        anchors.leftMargin: 9
        anchors.rightMargin: 9

        onClicked: commit()
    }
}
